﻿using Architecture.API.Application.TraceabilityCommand.AuxiliaryMaterialsCommand;
using MediatR;
using Traceability.Domain.Service.AuxiliaryMaterialsServices;
using Traceability.Domain.SupplierDomain;

namespace Architecture.API.Application.TraceabilityCommandHandler.AuxiliaryMaterialsCommandHanler
{
    public class UpdateAuxiliaryMaterialsCommandHanler : IRequestHandler<UpdateAuxiliaryMaterialsCommand, int>
    {
        /// <summary>
        /// 辅料服务
        /// </summary>
        protected readonly IAuxiliaryMaterialsService auxiliaryMaterialsService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="auxiliaryMaterialsService">辅料服务</param>
        public UpdateAuxiliaryMaterialsCommandHanler(IAuxiliaryMaterialsService auxiliaryMaterialsService)
        {
            this.auxiliaryMaterialsService = auxiliaryMaterialsService;
        }

        public async Task<int> Handle(UpdateAuxiliaryMaterialsCommand request, CancellationToken cancellationToken)
        {
            return await auxiliaryMaterialsService.UpdateAuxiliaryMaterials(new AuxiliaryMaterials() { AuxiliaryMaterialsId=request.AuxiliaryMaterialsId,AuxiliaryMaterialsProductionBatch=request.AuxiliaryMaterialsProductionBatch,UpdatedBy=request.UpdatedBy,UpdatedDate= DateTime.Now});
        }
    }
}
